package cn.tedu.eguser1.controller;

import cn.tedu.eguser1.base.response.JsonResult;
import cn.tedu.eguser1.mapper.UserMapper;
import cn.tedu.eguser1.pojo.dto.UserParam;
import cn.tedu.eguser1.pojo.entity.User;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@Slf4j
@RestController
@RequestMapping("v1/user/")
@Tag(name = "用户管理")
public class UserController {
    @Autowired
    private UserMapper userMapper;
    @PostMapping("addUser")
    public JsonResult addUser(@Validated UserParam userParam){
        log.debug("用户信息---" + userParam);
        User user = new User();
        BeanUtils.copyProperties(userParam,user);
        user.setCreateTime(new Date());
        user.setUpdateTime(new Date());
        userMapper.addUser(user);
        return JsonResult.ok();
    }
}
